#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author： 胡浩浩
# datetime： 2021/12/29 14:56 
# ide： PyCharm

from Models.caseModel import case_model
from typing import List
from sqlalchemy.orm import Session
from Tools.database import engine
from Dependencies.db_depedencies import get_db
from Controllers.caseController import case_controller
from Schemas.caseSchema import case_schema
from fastapi import APIRouter, Depends, HTTPException

case_model.Base.metadata.create_all(bind=engine)
router = APIRouter()


@router.get("/case/get/list", response_model=List[case_schema.Case])
async def read_case_list(skip: int = 0, limit: int = 10, db: Session = Depends(get_db)):
    case_list = case_controller.get_case_list(db=db, skip=skip, limit=limit)
    return case_list


@router.get("/case/get/{case_id}", response_model=case_schema.Case)
async def read_case_by_id(case_id: int, db: Session = Depends(get_db)):
    db_case = case_controller.get_case_by_id(db=db, case_id=case_id)
    return db_case


@router.post("/case/create", response_model=case_schema.Case)
async def create_case(case: case_schema.CaseCreate, db: Session = Depends(get_db)):
    db_case = case_controller.create_case(db=db, case=case)
    return db_case


async def create_case():
    pass
